package logic

import (
	"context"
	"house/models"

	"house/house"
	"house/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserUpLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserUpLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserUpLogic {
	return &UserUpLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 房源列表
func (l *UserUpLogic) UserUp(in *house.UserUpReq) (*house.UserUpResp, error) {
	// todo: 修改权限

	var err error
	var u models.User
	u.Status = int(in.Status)
	err = u.Update(int(in.UserId), int(in.Status))
	if err != nil {
		logx.Error("修改失败")
		return nil, err
	}

	return &house.UserUpResp{
		Id: int64(u.ID),
	}, nil
}
